<template>
  <a-table :columns="columns" :data-source="records" rowKey="id" bordered>
    <span slot="statusRender" slot-scope="text, record">
      <span v-if="record.isOk == '1'"> 是 </span>
      <span v-else> 否 </span>
    </span>
    <span slot="formatPlanFinishTime" slot-scope="text, record">
      {{ formatDate(record.planFinishTime, 'yyyy-MM-dd') }}
    </span>
  </a-table>
</template>

<script>
import { formatDate } from '@/utils/util'
import { getAction, postAction } from '@/api/manage'
export default {
  props: {
    contractId: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      columns: [
        {
          title: '节点内容',
          dataIndex: 'proContent',
          key: 'proContent',
        },
        {
          title: '条件',
          dataIndex: 'proConditions',
          key: 'proConditions',
        },
        {
          title: '与生效日期间隔天数',
          dataIndex: 'intervalDays',
          key: 'intervalDays',
        },
        {
          title: '预计完成时间',
          dataIndex: 'planFinishTime',
          key: 'planFinishTime',
          scopedSlots: { customRender: 'formatPlanFinishTime' },
        },
        {
          title: '提交资料内容',
          dataIndex: 'submitResources',
          key: 'submitResources',
        },
        {
          title: '验收人',
          dataIndex: 'accepter',
          key: 'accepter',
        },
        {
          title: '合同节点标识',
          dataIndex: 'contractNodeIdentify',
          key: 'contractNodeIdentify',
        },
        {
          title: '完成报工',
           dataIndex: 'isOk',
          key: 'isOk',
          scopedSlots: { customRender: 'statusRender' },
        },
      ],
      records: [],
      urls: {
        loadContractNodeDetails: '/hte/contract/loadContractNodeDetails',
      },
    }
  },
  mounted() {
    this.fetchList()
  },
  methods: {
    formatDate,
    fetchList() {
      getAction(this.urls.loadContractNodeDetails + '/' + this.contractId, {}).then((res) => {
        if (res.success) {
          this.records = res.result
        }
      })
    },
  },
  watch: {
    contractId(newV, oldV) {
      if (newV > 0) {
        this.fetchList()
      } else {
        this.records = []
      }
    },
  },
}
</script>

<style>
</style>